/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package session;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import entity.Users;
import entity.Accounts;

@Stateless
public class nowaBean implements nowaRemote {
@PersistenceContext(unitName="nowaPU")
	private EntityManager manager;

    public String createUser(Users user) {
       manager.persist(user);
        return user.getUName();
    }
    public void removeUser(String uName) {
       manager.remove(manager.find(Users.class, uName));
    }

    public Users findUser(String uName) {
       return manager.find(Users.class, uName);
    }

     public String createAccount(Accounts ac) {
        manager.persist(ac);
        return ac.getId();
    }

    public void removeAccount(String id) {
        manager.remove(manager.find(Users.class, id));
    }

    public Accounts findAccount(String id) {
        return manager.find(Accounts.class, id);
    }









}
